<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>test ajax</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<script type="text/javascript" src="../scripts/coos.js"></script>
<script type="text/javascript" src="../scripts/coos.ext.ajax.js"></script>
<script type="text/javascript">
function testPost()
{
	var url = "../getData?action=getPostData";
	var form = coos.$id("post_add");
	//no extend param
	//coos.ajax.post(url,postCallback,"post_add");
	
	//extend json object
	var id = form.id;
	//coos.ajax.post(url,postCallback,"post_add",{test1:id,test2:'bbb3'});
	
	//extend jsonStr
	var jsonStr = "{test1:'" + id + "',test2:'bbb3'}"
	var ext = jsonStr.toJson();
	//var ext = eval('(' + json + ')');
	coos.ajax.post(url,postCallback,"post_add",ext);
	
}
function postCallback(responseText,test1,test2)
{
	//{success:true,action:'getPostData',message:'test message'}
	alert("postCallback responseText = " + responseText);
	alert("postCallback is success = " + responseText.toJson().success);
	alert("postCallback message = " + responseText.toJson().message);
	alert("postCallback test1 = " + test1);
	alert("postCallback test2 = " + test2);
}
</script>
</head>
<body>
	<form action="" id="post_add" name="post_add" method="post" onsubmit="return false;">
		<textarea name="message" id="message">test message 测试中文</textarea>
		<input type="button" id="subBtn" value="submit" onclick="testPost()" />
	</form>
	<pre>
function testPost()
{
	var url = "../getData?action=getPostData";
	var form = coos.$id("post_add");
	//no extend param
	//coos.ajax.post(url,postCallback,"post_add");
	
	//extend json object
	var id = form.id;
	//coos.ajax.post(url,postCallback,"post_add",{test1:id,test2:'bbb3'});
	
	//extend jsonStr
	var jsonStr = "{test1:'" + id + "',test2:'bbb3'}"
	var ext = jsonStr.toJson();
	//var ext = eval('(' + json + ')');
	coos.ajax.post(url,postCallback,"post_add",ext);
	
}
function postCallback(responseText,test1,test2)
{
	//{success:true,action:'getPostData',message:'test message'}
	alert("postCallback responseText = " + responseText);
	alert("postCallback is success = " + responseText.toJson().success);
	alert("postCallback message = " + responseText.toJson().message);
	alert("postCallback test1 = " + test1);
	alert("postCallback test2 = " + test2);
}
	</pre>
</body>
</html>